package newsDemo.service.Impl;

import newsDemo.mapper.userMapper;
import newsDemo.pojo.user;
import newsDemo.service.userService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;

@Service
public class userServiceImpl implements userService {

    @Autowired
    private userMapper userMapper;

    @Override
    public void add(String name, String pwd) {
        Random r = new Random();
        int key = 1000000 + r.nextInt(9000000);
        userMapper.add(new user(name, pwd, String.valueOf(key)));
    }

    @Override
    public user select(String name) {
        return userMapper.findByName(name);
    }

    @Override
    public void update(user user) {
        userMapper.update(user);
    }

    @Override
    public void delete(int id) {
        userMapper.delete(id);
    }
}
